package com.gitee.dufafei.spark.listener

import org.apache.spark.streaming.StreamingContext
import org.apache.spark.streaming.scheduler.{StreamingListener, StreamingListenerBatchStarted}

import scala.collection.mutable.ArrayBuffer

/**
  * 监控spark-streaming
  */
class ISparkStreamingListener(ssc:StreamingContext) extends StreamingListener {

  val msg = new ArrayBuffer[String]()
  msg.append("应用程序ID：" + ssc.sparkContext.applicationId)
  msg.append("应用程序名称：" + ssc.sparkContext.appName)

  override def onBatchStarted(batchStarted: StreamingListenerBatchStarted): Unit = {
    //当前调度等待时间
    val delayTs = batchStarted.batchInfo.schedulingDelay.get / (1000 * 60D)
  }
}
